<!-- HTML header for doxygen 1.8.20-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=9"/>
	<meta name="generator" content="Doxygen 1.9.4"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title>Raspberry Pi Pico SDK: hardware_spi</title>
	<!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="dynsections.js"></script>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
	<link href="doxygen.css" rel="stylesheet" type="text/css" />
	<link href="normalise.css" rel="stylesheet" type="text/css"/>
<link href="main.css" rel="stylesheet" type="text/css"/>
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
	<div class="navigation-mobile">
		<div class="logo--mobile">
			<a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
		</div>
		<div class="navigation-toggle">
			<span class="line-1"></span>
			<span class="line-2">
				<p>Menu Toggle</p>
			</span>
			<span class="line-3"></span>
		</div>
	</div>
	<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
		<div class="logo">
			<a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
			<span style="display: inline-block; margin-top: 10px;">
				v2.1.0
			</span>
		</div>
		<div class="navigation-footer">
			<img src="logo-mobile.svg" alt="Raspberry Pi">
			<a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
		</div>
<!-- 		<div class="search">
			<form>
				<input type="search" name="search" id="search" placeholder="Search">
				<input type="submit" value="Search">
			</form>
		</div> -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__hardware__spi.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">hardware_spi<div class="ingroups"><a class="el" href="group__hardware.html">Hardware APIs</a></div></div></div>
</div><!--header-->
<div class="contents">

<p>Hardware SPI API.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga9d931d2e2e5b1dfd8d5f1dea80df4dbd"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a>&#160;&#160;&#160;((<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *)spi0_hw)</td></tr>
<tr class="separator:ga9d931d2e2e5b1dfd8d5f1dea80df4dbd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3de59ab064bc9405b059edce4366c694"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a>&#160;&#160;&#160;((<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *)spi1_hw)</td></tr>
<tr class="separator:ga3de59ab064bc9405b059edce4366c694"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga39308f1ccde24d91e0075059b380dd3a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga39308f1ccde24d91e0075059b380dd3a">SPI_NUM</a>(spi)</td></tr>
<tr class="memdesc:ga39308f1ccde24d91e0075059b380dd3a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the SPI number for a SPI instance.  <a href="group__hardware__spi.html#ga39308f1ccde24d91e0075059b380dd3a">More...</a><br /></td></tr>
<tr class="separator:ga39308f1ccde24d91e0075059b380dd3a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae1d6ac7c86e9f76d5c1a38c6dfd978b9"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#gae1d6ac7c86e9f76d5c1a38c6dfd978b9">SPI_INSTANCE</a>(num)</td></tr>
<tr class="memdesc:gae1d6ac7c86e9f76d5c1a38c6dfd978b9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the SPI instance with the given SPI number.  <a href="group__hardware__spi.html#gae1d6ac7c86e9f76d5c1a38c6dfd978b9">More...</a><br /></td></tr>
<tr class="separator:gae1d6ac7c86e9f76d5c1a38c6dfd978b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa470b3363ffe872bba90d31814d33baa"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#gaa470b3363ffe872bba90d31814d33baa">SPI_DREQ_NUM</a>(spi,  is_tx)</td></tr>
<tr class="memdesc:gaa470b3363ffe872bba90d31814d33baa"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the <a class="el" href="group__hardware__dma.html#ga8def0ea481095c94f3a0dd0b4fed999e">dreq_num_t</a> used for pacing DMA transfers to or from this SPI instance. If is_tx is true, then it is for transfers to the SPI else for transfers from the SPI.  <a href="group__hardware__spi.html#gaa470b3363ffe872bba90d31814d33baa">More...</a><br /></td></tr>
<tr class="separator:gaa470b3363ffe872bba90d31814d33baa"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="enum-members" name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:ga9850de61d3f6dcacbfb4e5cc5a7d2951"><td class="memItemLeft" align="right" valign="top"><a id="ga9850de61d3f6dcacbfb4e5cc5a7d2951" name="ga9850de61d3f6dcacbfb4e5cc5a7d2951"></a>enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga9850de61d3f6dcacbfb4e5cc5a7d2951">spi_cpha_t</a> { <b>SPI_CPHA_0</b> = 0
, <b>SPI_CPHA_1</b> = 1
 }</td></tr>
<tr class="memdesc:ga9850de61d3f6dcacbfb4e5cc5a7d2951"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enumeration of SPI CPHA (clock phase) values. <br /></td></tr>
<tr class="separator:ga9850de61d3f6dcacbfb4e5cc5a7d2951"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga49a77d9a0320db6d3451a9dda2b8a24b"><td class="memItemLeft" align="right" valign="top"><a id="ga49a77d9a0320db6d3451a9dda2b8a24b" name="ga49a77d9a0320db6d3451a9dda2b8a24b"></a>enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga49a77d9a0320db6d3451a9dda2b8a24b">spi_cpol_t</a> { <b>SPI_CPOL_0</b> = 0
, <b>SPI_CPOL_1</b> = 1
 }</td></tr>
<tr class="memdesc:ga49a77d9a0320db6d3451a9dda2b8a24b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enumeration of SPI CPOL (clock polarity) values. <br /></td></tr>
<tr class="separator:ga49a77d9a0320db6d3451a9dda2b8a24b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa9e8effacf4291301048ef7df03d353e"><td class="memItemLeft" align="right" valign="top"><a id="gaa9e8effacf4291301048ef7df03d353e" name="gaa9e8effacf4291301048ef7df03d353e"></a>enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#gaa9e8effacf4291301048ef7df03d353e">spi_order_t</a> { <b>SPI_LSB_FIRST</b> = 0
, <b>SPI_MSB_FIRST</b> = 1
 }</td></tr>
<tr class="memdesc:gaa9e8effacf4291301048ef7df03d353e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enumeration of SPI bit-order values. <br /></td></tr>
<tr class="separator:gaa9e8effacf4291301048ef7df03d353e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga1dba14fb5488b5e4a69b30678f774df0"><td class="memItemLeft" align="right" valign="top">uint&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga1dba14fb5488b5e4a69b30678f774df0">spi_init</a> (<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, uint baudrate)</td></tr>
<tr class="memdesc:ga1dba14fb5488b5e4a69b30678f774df0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialise SPI instances.  <a href="group__hardware__spi.html#ga1dba14fb5488b5e4a69b30678f774df0">More...</a><br /></td></tr>
<tr class="separator:ga1dba14fb5488b5e4a69b30678f774df0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf0c3a38c80cf84a80602755d7bac77e2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#gaf0c3a38c80cf84a80602755d7bac77e2">spi_deinit</a> (<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi)</td></tr>
<tr class="memdesc:gaf0c3a38c80cf84a80602755d7bac77e2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Deinitialise SPI instances.  <a href="group__hardware__spi.html#gaf0c3a38c80cf84a80602755d7bac77e2">More...</a><br /></td></tr>
<tr class="separator:gaf0c3a38c80cf84a80602755d7bac77e2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga37f4c04ce4165ac8c129226336a0b66c"><td class="memItemLeft" align="right" valign="top">uint&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga37f4c04ce4165ac8c129226336a0b66c">spi_set_baudrate</a> (<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, uint baudrate)</td></tr>
<tr class="memdesc:ga37f4c04ce4165ac8c129226336a0b66c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set SPI baudrate.  <a href="group__hardware__spi.html#ga37f4c04ce4165ac8c129226336a0b66c">More...</a><br /></td></tr>
<tr class="separator:ga37f4c04ce4165ac8c129226336a0b66c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa295443736ab03ac882f2d9383cac139"><td class="memItemLeft" align="right" valign="top">uint&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#gaa295443736ab03ac882f2d9383cac139">spi_get_baudrate</a> (const <a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi)</td></tr>
<tr class="memdesc:gaa295443736ab03ac882f2d9383cac139"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get SPI baudrate.  <a href="group__hardware__spi.html#gaa295443736ab03ac882f2d9383cac139">More...</a><br /></td></tr>
<tr class="separator:gaa295443736ab03ac882f2d9383cac139"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga88620398eae6e0f66b551be57a279273"><td class="memItemLeft" align="right" valign="top">static uint&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga88620398eae6e0f66b551be57a279273">spi_get_index</a> (const <a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi)</td></tr>
<tr class="memdesc:ga88620398eae6e0f66b551be57a279273"><td class="mdescLeft">&#160;</td><td class="mdescRight">Convert SPI instance to hardware instance number.  <a href="group__hardware__spi.html#ga88620398eae6e0f66b551be57a279273">More...</a><br /></td></tr>
<tr class="separator:ga88620398eae6e0f66b551be57a279273"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga137168d01d302239d52420ad4f895d44"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga137168d01d302239d52420ad4f895d44">spi_set_format</a> (<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, uint data_bits, <a class="el" href="group__hardware__spi.html#ga49a77d9a0320db6d3451a9dda2b8a24b">spi_cpol_t</a> cpol, <a class="el" href="group__hardware__spi.html#ga9850de61d3f6dcacbfb4e5cc5a7d2951">spi_cpha_t</a> cpha, __unused <a class="el" href="group__hardware__spi.html#gaa9e8effacf4291301048ef7df03d353e">spi_order_t</a> order)</td></tr>
<tr class="memdesc:ga137168d01d302239d52420ad4f895d44"><td class="mdescLeft">&#160;</td><td class="mdescRight">Configure SPI.  <a href="group__hardware__spi.html#ga137168d01d302239d52420ad4f895d44">More...</a><br /></td></tr>
<tr class="separator:ga137168d01d302239d52420ad4f895d44"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga127e4bf0fc1d7d271d2e9160c6e3b722"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga127e4bf0fc1d7d271d2e9160c6e3b722">spi_set_slave</a> (<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, bool slave)</td></tr>
<tr class="memdesc:ga127e4bf0fc1d7d271d2e9160c6e3b722"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set SPI master/slave.  <a href="group__hardware__spi.html#ga127e4bf0fc1d7d271d2e9160c6e3b722">More...</a><br /></td></tr>
<tr class="separator:ga127e4bf0fc1d7d271d2e9160c6e3b722"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0d7c020fac16f57ee8f805000713e405"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga0d7c020fac16f57ee8f805000713e405">spi_is_writable</a> (const <a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi)</td></tr>
<tr class="memdesc:ga0d7c020fac16f57ee8f805000713e405"><td class="mdescLeft">&#160;</td><td class="mdescRight">Check whether a write can be done on SPI device.  <a href="group__hardware__spi.html#ga0d7c020fac16f57ee8f805000713e405">More...</a><br /></td></tr>
<tr class="separator:ga0d7c020fac16f57ee8f805000713e405"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga20dcaa3037e92bbcbab50b8635f102ff"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga20dcaa3037e92bbcbab50b8635f102ff">spi_is_readable</a> (const <a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi)</td></tr>
<tr class="memdesc:ga20dcaa3037e92bbcbab50b8635f102ff"><td class="mdescLeft">&#160;</td><td class="mdescRight">Check whether a read can be done on SPI device.  <a href="group__hardware__spi.html#ga20dcaa3037e92bbcbab50b8635f102ff">More...</a><br /></td></tr>
<tr class="separator:ga20dcaa3037e92bbcbab50b8635f102ff"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5623d0396207ccbd3faa64a5d4f397c3"><td class="memItemLeft" align="right" valign="top">static bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga5623d0396207ccbd3faa64a5d4f397c3">spi_is_busy</a> (const <a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi)</td></tr>
<tr class="memdesc:ga5623d0396207ccbd3faa64a5d4f397c3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Check whether SPI is busy.  <a href="group__hardware__spi.html#ga5623d0396207ccbd3faa64a5d4f397c3">More...</a><br /></td></tr>
<tr class="separator:ga5623d0396207ccbd3faa64a5d4f397c3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabb840d4e3db64ea70fad6bb740717910"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#gabb840d4e3db64ea70fad6bb740717910">spi_write_read_blocking</a> (<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, const uint8_t *src, uint8_t *dst, size_t len)</td></tr>
<tr class="memdesc:gabb840d4e3db64ea70fad6bb740717910"><td class="mdescLeft">&#160;</td><td class="mdescRight">Write/Read to/from an SPI device.  <a href="group__hardware__spi.html#gabb840d4e3db64ea70fad6bb740717910">More...</a><br /></td></tr>
<tr class="separator:gabb840d4e3db64ea70fad6bb740717910"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga541ec2a1eee4c7fee2134a8415f3b4c8"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga541ec2a1eee4c7fee2134a8415f3b4c8">spi_write_blocking</a> (<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, const uint8_t *src, size_t len)</td></tr>
<tr class="memdesc:ga541ec2a1eee4c7fee2134a8415f3b4c8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Write to an SPI device, blocking.  <a href="group__hardware__spi.html#ga541ec2a1eee4c7fee2134a8415f3b4c8">More...</a><br /></td></tr>
<tr class="separator:ga541ec2a1eee4c7fee2134a8415f3b4c8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga40ce84e76797f81872f12557e537fc48"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga40ce84e76797f81872f12557e537fc48">spi_read_blocking</a> (<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, uint8_t repeated_tx_data, uint8_t *dst, size_t len)</td></tr>
<tr class="memdesc:ga40ce84e76797f81872f12557e537fc48"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read from an SPI device.  <a href="group__hardware__spi.html#ga40ce84e76797f81872f12557e537fc48">More...</a><br /></td></tr>
<tr class="separator:ga40ce84e76797f81872f12557e537fc48"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad3b96ae828fec8af4b0617db7e904019"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#gad3b96ae828fec8af4b0617db7e904019">spi_write16_read16_blocking</a> (<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, const uint16_t *src, uint16_t *dst, size_t len)</td></tr>
<tr class="memdesc:gad3b96ae828fec8af4b0617db7e904019"><td class="mdescLeft">&#160;</td><td class="mdescRight">Write/Read half words to/from an SPI device.  <a href="group__hardware__spi.html#gad3b96ae828fec8af4b0617db7e904019">More...</a><br /></td></tr>
<tr class="separator:gad3b96ae828fec8af4b0617db7e904019"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacff6be19b2de92a34b295597f3ae8572"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#gacff6be19b2de92a34b295597f3ae8572">spi_write16_blocking</a> (<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, const uint16_t *src, size_t len)</td></tr>
<tr class="memdesc:gacff6be19b2de92a34b295597f3ae8572"><td class="mdescLeft">&#160;</td><td class="mdescRight">Write to an SPI device.  <a href="group__hardware__spi.html#gacff6be19b2de92a34b295597f3ae8572">More...</a><br /></td></tr>
<tr class="separator:gacff6be19b2de92a34b295597f3ae8572"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga743b7fbdf120a1b5fc098145e3ce8eaf"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga743b7fbdf120a1b5fc098145e3ce8eaf">spi_read16_blocking</a> (<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, uint16_t repeated_tx_data, uint16_t *dst, size_t len)</td></tr>
<tr class="memdesc:ga743b7fbdf120a1b5fc098145e3ce8eaf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read from an SPI device.  <a href="group__hardware__spi.html#ga743b7fbdf120a1b5fc098145e3ce8eaf">More...</a><br /></td></tr>
<tr class="separator:ga743b7fbdf120a1b5fc098145e3ce8eaf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6241d6c368b1af1b83a12c1e75515486"><td class="memItemLeft" align="right" valign="top">static uint&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__hardware__spi.html#ga6241d6c368b1af1b83a12c1e75515486">spi_get_dreq</a> (<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, bool is_tx)</td></tr>
<tr class="memdesc:ga6241d6c368b1af1b83a12c1e75515486"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the DREQ to use for pacing transfers to/from a particular SPI instance.  <a href="group__hardware__spi.html#ga6241d6c368b1af1b83a12c1e75515486">More...</a><br /></td></tr>
<tr class="separator:ga6241d6c368b1af1b83a12c1e75515486"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p >Hardware SPI API. </p>
<p >RP-series microcontrollers have 2 identical instances of the Serial Peripheral Interface (SPI) controller.</p>
<p >The PrimeCell SSP is a master or slave interface for synchronous serial communication with peripheral devices that have Motorola SPI, National Semiconductor Microwire, or Texas Instruments synchronous serial interfaces.</p>
<p >Controller can be defined as master or slave using the <a class="el" href="group__hardware__spi.html#ga127e4bf0fc1d7d271d2e9160c6e3b722">spi_set_slave</a> function.</p>
<p >Each controller can be connected to a number of GPIO pins, see the datasheet GPIO function selection table for more information. </p>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ga9d931d2e2e5b1dfd8d5f1dea80df4dbd" name="ga9d931d2e2e5b1dfd8d5f1dea80df4dbd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">&#9670;&nbsp;</a></span>spi0</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define spi0&#160;&#160;&#160;((<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *)spi0_hw)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p >Identifier for the first (SPI 0) hardware SPI instance (for use in SPI functions).</p>
<p >e.g. spi_init(spi0, 48000) </p>

</div>
</div>
<a id="ga3de59ab064bc9405b059edce4366c694" name="ga3de59ab064bc9405b059edce4366c694"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3de59ab064bc9405b059edce4366c694">&#9670;&nbsp;</a></span>spi1</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define spi1&#160;&#160;&#160;((<a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *)spi1_hw)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p >Identifier for the second (SPI 1) hardware SPI instance (for use in SPI functions).</p>
<p >e.g. spi_init(spi1, 48000) </p>

</div>
</div>
<a id="gaa470b3363ffe872bba90d31814d33baa" name="gaa470b3363ffe872bba90d31814d33baa"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa470b3363ffe872bba90d31814d33baa">&#9670;&nbsp;</a></span>SPI_DREQ_NUM</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SPI_DREQ_NUM</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">spi, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">is_tx&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the <a class="el" href="group__hardware__dma.html#ga8def0ea481095c94f3a0dd0b4fed999e">dreq_num_t</a> used for pacing DMA transfers to or from this SPI instance. If is_tx is true, then it is for transfers to the SPI else for transfers from the SPI. </p>
<p >Note this macro is intended to resolve at compile time, and does no parameter checking </p>

</div>
</div>
<a id="gae1d6ac7c86e9f76d5c1a38c6dfd978b9" name="gae1d6ac7c86e9f76d5c1a38c6dfd978b9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae1d6ac7c86e9f76d5c1a38c6dfd978b9">&#9670;&nbsp;</a></span>SPI_INSTANCE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SPI_INSTANCE</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">num</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the SPI instance with the given SPI number. </p>
<p >Note this macro is intended to resolve at compile time, and does no parameter checking </p>

</div>
</div>
<a id="ga39308f1ccde24d91e0075059b380dd3a" name="ga39308f1ccde24d91e0075059b380dd3a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga39308f1ccde24d91e0075059b380dd3a">&#9670;&nbsp;</a></span>SPI_NUM</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SPI_NUM</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">spi</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Returns the SPI number for a SPI instance. </p>
<p >Note this macro is intended to resolve at compile time, and does no parameter checking </p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="gaf0c3a38c80cf84a80602755d7bac77e2" name="gaf0c3a38c80cf84a80602755d7bac77e2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf0c3a38c80cf84a80602755d7bac77e2">&#9670;&nbsp;</a></span>spi_deinit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void spi_deinit </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Deinitialise SPI instances. </p>
<p >Puts the SPI into a disabled state. Init will need to be called to re-enable the device functions.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gaa295443736ab03ac882f2d9383cac139" name="gaa295443736ab03ac882f2d9383cac139"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa295443736ab03ac882f2d9383cac139">&#9670;&nbsp;</a></span>spi_get_baudrate()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint spi_get_baudrate </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get SPI baudrate. </p>
<p >Get SPI baudrate which was set by </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="group__hardware__spi.html#ga37f4c04ce4165ac8c129226336a0b66c" title="Set SPI baudrate.">spi_set_baudrate</a></dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The actual baudrate set </dd></dl>

</div>
</div>
<a id="ga6241d6c368b1af1b83a12c1e75515486" name="ga6241d6c368b1af1b83a12c1e75515486"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6241d6c368b1af1b83a12c1e75515486">&#9670;&nbsp;</a></span>spi_get_dreq()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static uint spi_get_dreq </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>is_tx</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return the DREQ to use for pacing transfers to/from a particular SPI instance. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
    <tr><td class="paramname">is_tx</td><td>true for sending data to the SPI instance, false for receiving data from the SPI instance </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga88620398eae6e0f66b551be57a279273" name="ga88620398eae6e0f66b551be57a279273"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga88620398eae6e0f66b551be57a279273">&#9670;&nbsp;</a></span>spi_get_index()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static uint spi_get_index </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Convert SPI instance to hardware instance number. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Number of SPI, 0 or 1. </dd></dl>

</div>
</div>
<a id="ga1dba14fb5488b5e4a69b30678f774df0" name="ga1dba14fb5488b5e4a69b30678f774df0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga1dba14fb5488b5e4a69b30678f774df0">&#9670;&nbsp;</a></span>spi_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint spi_init </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint&#160;</td>
          <td class="paramname"><em>baudrate</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialise SPI instances. </p>
<p >Puts the SPI into a known state, and enable it. Must be called before other functions.</p>
<dl class="section note"><dt>Note</dt><dd>There is no guarantee that the baudrate requested can be achieved exactly; the nearest will be chosen and returned</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
    <tr><td class="paramname">baudrate</td><td>Baudrate requested in Hz </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the actual baud rate set </dd></dl>

</div>
</div>
<a id="ga5623d0396207ccbd3faa64a5d4f397c3" name="ga5623d0396207ccbd3faa64a5d4f397c3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga5623d0396207ccbd3faa64a5d4f397c3">&#9670;&nbsp;</a></span>spi_is_busy()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static bool spi_is_busy </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Check whether SPI is busy. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if SPI is busy </dd></dl>

</div>
</div>
<a id="ga20dcaa3037e92bbcbab50b8635f102ff" name="ga20dcaa3037e92bbcbab50b8635f102ff"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga20dcaa3037e92bbcbab50b8635f102ff">&#9670;&nbsp;</a></span>spi_is_readable()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static bool spi_is_readable </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Check whether a read can be done on SPI device. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if a read is possible i.e. data is present </dd></dl>

</div>
</div>
<a id="ga0d7c020fac16f57ee8f805000713e405" name="ga0d7c020fac16f57ee8f805000713e405"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0d7c020fac16f57ee8f805000713e405">&#9670;&nbsp;</a></span>spi_is_writable()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static bool spi_is_writable </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Check whether a write can be done on SPI device. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>false if no space is available to write. True if a write is possible </dd></dl>

</div>
</div>
<a id="ga743b7fbdf120a1b5fc098145e3ce8eaf" name="ga743b7fbdf120a1b5fc098145e3ce8eaf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga743b7fbdf120a1b5fc098145e3ce8eaf">&#9670;&nbsp;</a></span>spi_read16_blocking()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int spi_read16_blocking </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>repeated_tx_data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t *&#160;</td>
          <td class="paramname"><em>dst</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Read from an SPI device. </p>
<p >Read <code>len</code> halfwords from SPI to <code>dst</code>. Blocks until all data is transferred. No timeout, as SPI hardware always transfers at a known data rate. <code>repeated_tx_data</code> is output repeatedly on TX as data is read in from RX. Generally this can be 0, but some devices require a specific value here, e.g. SD cards expect 0xff</p>
<dl class="section note"><dt>Note</dt><dd>SPI should be initialised with 16 data_bits using <a class="el" href="group__hardware__spi.html#ga137168d01d302239d52420ad4f895d44">spi_set_format</a> first, otherwise this function will only read 8 data_bits.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
    <tr><td class="paramname">repeated_tx_data</td><td>Buffer of data to write </td></tr>
    <tr><td class="paramname">dst</td><td>Buffer for read data </td></tr>
    <tr><td class="paramname">len</td><td>Length of buffer <code>dst</code> in halfwords </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Number of halfwords written/read </dd></dl>

</div>
</div>
<a id="ga40ce84e76797f81872f12557e537fc48" name="ga40ce84e76797f81872f12557e537fc48"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga40ce84e76797f81872f12557e537fc48">&#9670;&nbsp;</a></span>spi_read_blocking()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int spi_read_blocking </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>repeated_tx_data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>dst</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Read from an SPI device. </p>
<p >Read <code>len</code> bytes from SPI to <code>dst</code>. Blocks until all data is transferred. No timeout, as SPI hardware always transfers at a known data rate. <code>repeated_tx_data</code> is output repeatedly on TX as data is read in from RX. Generally this can be 0, but some devices require a specific value here, e.g. SD cards expect 0xff</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
    <tr><td class="paramname">repeated_tx_data</td><td>Buffer of data to write </td></tr>
    <tr><td class="paramname">dst</td><td>Buffer for read data </td></tr>
    <tr><td class="paramname">len</td><td>Length of buffer <code>dst</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Number of bytes written/read </dd></dl>

</div>
</div>
<a id="ga37f4c04ce4165ac8c129226336a0b66c" name="ga37f4c04ce4165ac8c129226336a0b66c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga37f4c04ce4165ac8c129226336a0b66c">&#9670;&nbsp;</a></span>spi_set_baudrate()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint spi_set_baudrate </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint&#160;</td>
          <td class="paramname"><em>baudrate</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set SPI baudrate. </p>
<p >Set SPI frequency as close as possible to baudrate, and return the actual achieved rate.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
    <tr><td class="paramname">baudrate</td><td>Baudrate required in Hz, should be capable of a bitrate of at least 2Mbps, or higher, depending on system clock settings. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The actual baudrate set </dd></dl>

</div>
</div>
<a id="ga137168d01d302239d52420ad4f895d44" name="ga137168d01d302239d52420ad4f895d44"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga137168d01d302239d52420ad4f895d44">&#9670;&nbsp;</a></span>spi_set_format()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void spi_set_format </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint&#160;</td>
          <td class="paramname"><em>data_bits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__hardware__spi.html#ga49a77d9a0320db6d3451a9dda2b8a24b">spi_cpol_t</a>&#160;</td>
          <td class="paramname"><em>cpol</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__hardware__spi.html#ga9850de61d3f6dcacbfb4e5cc5a7d2951">spi_cpha_t</a>&#160;</td>
          <td class="paramname"><em>cpha</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">__unused <a class="el" href="group__hardware__spi.html#gaa9e8effacf4291301048ef7df03d353e">spi_order_t</a>&#160;</td>
          <td class="paramname"><em>order</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Configure SPI. </p>
<p >Configure how the SPI serialises and deserialises data on the wire</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
    <tr><td class="paramname">data_bits</td><td>Number of data bits per transfer. Valid values 4..16. </td></tr>
    <tr><td class="paramname">cpol</td><td>SSPCLKOUT polarity, applicable to Motorola SPI frame format only. </td></tr>
    <tr><td class="paramname">cpha</td><td>SSPCLKOUT phase, applicable to Motorola SPI frame format only </td></tr>
    <tr><td class="paramname">order</td><td>Must be SPI_MSB_FIRST, no other values supported on the PL022 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga127e4bf0fc1d7d271d2e9160c6e3b722" name="ga127e4bf0fc1d7d271d2e9160c6e3b722"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga127e4bf0fc1d7d271d2e9160c6e3b722">&#9670;&nbsp;</a></span>spi_set_slave()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void spi_set_slave </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>slave</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Set SPI master/slave. </p>
<p >Configure the SPI for master- or slave-mode operation. By default, <a class="el" href="group__hardware__spi.html#ga1dba14fb5488b5e4a69b30678f774df0" title="Initialise SPI instances.">spi_init()</a> sets master-mode.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
    <tr><td class="paramname">slave</td><td>true to set SPI device as a slave device, false for master. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gacff6be19b2de92a34b295597f3ae8572" name="gacff6be19b2de92a34b295597f3ae8572"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacff6be19b2de92a34b295597f3ae8572">&#9670;&nbsp;</a></span>spi_write16_blocking()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int spi_write16_blocking </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint16_t *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Write to an SPI device. </p>
<p >Write <code>len</code> halfwords from <code>src</code> to SPI. Discard any data received back. Blocks until all data is transferred. No timeout, as SPI hardware always transfers at a known data rate.</p>
<dl class="section note"><dt>Note</dt><dd>SPI should be initialised with 16 data_bits using <a class="el" href="group__hardware__spi.html#ga137168d01d302239d52420ad4f895d44">spi_set_format</a> first, otherwise this function will only write 8 data_bits.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
    <tr><td class="paramname">src</td><td>Buffer of data to write </td></tr>
    <tr><td class="paramname">len</td><td>Length of buffers </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Number of halfwords written/read </dd></dl>

</div>
</div>
<a id="gad3b96ae828fec8af4b0617db7e904019" name="gad3b96ae828fec8af4b0617db7e904019"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad3b96ae828fec8af4b0617db7e904019">&#9670;&nbsp;</a></span>spi_write16_read16_blocking()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int spi_write16_read16_blocking </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint16_t *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t *&#160;</td>
          <td class="paramname"><em>dst</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Write/Read half words to/from an SPI device. </p>
<p >Write <code>len</code> halfwords from <code>src</code> to SPI. Simultaneously read <code>len</code> halfwords from SPI to <code>dst</code>. Blocks until all data is transferred. No timeout, as SPI hardware always transfers at a known data rate.</p>
<dl class="section note"><dt>Note</dt><dd>SPI should be initialised with 16 data_bits using <a class="el" href="group__hardware__spi.html#ga137168d01d302239d52420ad4f895d44">spi_set_format</a> first, otherwise this function will only read/write 8 data_bits.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
    <tr><td class="paramname">src</td><td>Buffer of data to write </td></tr>
    <tr><td class="paramname">dst</td><td>Buffer for read data </td></tr>
    <tr><td class="paramname">len</td><td>Length of BOTH buffers in halfwords </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Number of halfwords written/read </dd></dl>

</div>
</div>
<a id="ga541ec2a1eee4c7fee2134a8415f3b4c8" name="ga541ec2a1eee4c7fee2134a8415f3b4c8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga541ec2a1eee4c7fee2134a8415f3b4c8">&#9670;&nbsp;</a></span>spi_write_blocking()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int spi_write_blocking </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Write to an SPI device, blocking. </p>
<p >Write <code>len</code> bytes from <code>src</code> to SPI, and discard any data received back Blocks until all data is transferred. No timeout, as SPI hardware always transfers at a known data rate.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
    <tr><td class="paramname">src</td><td>Buffer of data to write </td></tr>
    <tr><td class="paramname">len</td><td>Length of <code>src</code> </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Number of bytes written/read </dd></dl>

</div>
</div>
<a id="gabb840d4e3db64ea70fad6bb740717910" name="gabb840d4e3db64ea70fad6bb740717910"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gabb840d4e3db64ea70fad6bb740717910">&#9670;&nbsp;</a></span>spi_write_read_blocking()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int spi_write_read_blocking </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *&#160;</td>
          <td class="paramname"><em>spi</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const uint8_t *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>dst</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Write/Read to/from an SPI device. </p>
<p >Write <code>len</code> bytes from <code>src</code> to SPI. Simultaneously read <code>len</code> bytes from SPI to <code>dst</code>. Blocks until all data is transferred. No timeout, as SPI hardware always transfers at a known data rate.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">spi</td><td>SPI instance specifier, either <a class="el" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> or <a class="el" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a> </td></tr>
    <tr><td class="paramname">src</td><td>Buffer of data to write </td></tr>
    <tr><td class="paramname">dst</td><td>Buffer for read data </td></tr>
    <tr><td class="paramname">len</td><td>Length of BOTH buffers </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Number of bytes written/read </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->

	<script src="main.js"></script>
</body>
</html>